
const fs = require("fs").promises;
const path = require("path");

function fn(){
    console.log('info')
}

Promise.prototype.finally = function(cb){
    return this.then((data)=>{
        return Promise.resolve(cb()).then(()=>data)
    },(reason)=>{
        return Promise.resolve(cb()).then(()=>{throw reason})
    })
}

fs.readFile(path.resolve(__dirname,'./note.md'),'utf8').finally(()=>{
    return new Promise((resolve,reject)=>{
        setTimeout(() => {
            reject('ok')
        }, 3000);
    })

    
}).then(data=>{
    console.log('data',data)
}).catch(err=>{
    console.log('err',err)
})